package com.example.admin.controller.web.system;

import java.util.Arrays;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.common.system.entity.UserRoleEntity;
import com.example.common.system.service.UserRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.example.common.util.PageUtils;
import com.example.common.core.response.AjaxResult;



/**
 * 用户角色关联表
 *
 * @author chen
 * @email 17635014889@163.com
 * @date 2022-09-20 10:33:50
 */
@RestController
@RequestMapping("/system/userrole")
public class UserRoleController {
    @Autowired
    private UserRoleService userRoleService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    //@RequiresPermissions("system:userrole:list")
    public AjaxResult list(Page<UserRoleEntity> page, UserRoleEntity userRoleEntity){
        PageUtils result = userRoleService.queryPage(page,userRoleEntity);

        return AjaxResult.success(result);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    //@RequiresPermissions("system:userrole:info")
    public AjaxResult info(@PathVariable("id") Integer id){
		UserRoleEntity userRole = userRoleService.getById(id);

        return AjaxResult.success(userRole);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("system:userrole:save")
    public AjaxResult save(@RequestBody UserRoleEntity userRole){
		userRoleService.save(userRole);

        return AjaxResult.success();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions("system:userrole:update")
    public AjaxResult update(@RequestBody UserRoleEntity userRole){
		userRoleService.updateById(userRole);

        return AjaxResult.success();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("system:userrole:delete")
    public AjaxResult delete(@RequestBody Integer[] ids){
		userRoleService.removeByIds(Arrays.asList(ids));

        return AjaxResult.success();
    }

}
